//
//  UpDownButton.m
//  SheShiDu
//
//  Created by 单剑秋 on 16/6/12.
//  Copyright © 2016年 单剑秋. All rights reserved.
//

#import "UpDownButton.h"

@implementation UpDownButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    if (self.titleLabel.frame.origin.x != 0) {
       
        CGRect tempImageViewRect = self.imageView.frame;
        tempImageViewRect.origin.x = self.frame.size.width / 2 - self.frame.size.width / 10 * 3;
        tempImageViewRect.origin.y = 0;
        tempImageViewRect.size.height = self.frame.size.width / 5 * 3;
        tempImageViewRect.size.width = self.frame.size.width / 5 * 3;
        self.imageView.frame = tempImageViewRect;
        
        CGRect tempTitleLabelRect = self.titleLabel.frame;
        tempTitleLabelRect.origin.y = self.imageView.frame.size.height + self.imageView.frame.origin.y + 5;
        tempTitleLabelRect.size.width = self.frame.size.width;
        tempTitleLabelRect.origin.x = 0;
        self.titleLabel.frame = tempTitleLabelRect;
        
    }
    
   
}

@end
